#@layout()
#define main()

<script type="text/javascript">
	var isExport = false;

	//改变提交标志位
	var changeBooleanExport = function(submitObj){
		//console.log($(submitObj).attr("value"));
		var submitType = $(submitObj).attr("value");
		if(submitType == '导出'){
			isExport = true;
		}else{
			isExport = false;
		}
	}

	//根据 提交的按钮 改变 提交 URL
	var changeUrl = function(formObj){
		console.log($(formObj).attr("action"));
		var ctxPath = $(formObj).attr("action");
		if(isExport){
			$(formObj).attr("action",ctxPath+"/weekreport/download")
		}else{
			$(formObj).attr("action",ctxPath+"/weekreport/index")
		}

		return true;
	}
	//显示一条记录的详细情况
	var openDetail = function(id){
		$( "#dialog_"+id ).dialog();
	}

	$(function() {
		//$( "#dialog" ).dialog();
	});
</script>
<h1>
	<form action="#(ctx??)" method="post" onsubmit="return changeUrl(this)">
		<fieldset class="solid">
			<legend>菜单</legend>
			<span>
				<label>起始时间:</label>
				<input type="date" name="startTime" value="#(startTime)" />
			</span>
			<span>
				<label>结束时间:</label>
				<input type="date" name="endTime" value="#(endTime)" />
			</span>
			<span>
				<label></label>
				<input value="查询" type="submit" onclick="changeBooleanExport(this)">
				<input value="导出" type="submit" onclick="changeBooleanExport(this)">
				<a href="#(ctx??)/weekreport/add" class="red">创建</a>
			</span>
		</fieldset>
	</form>
</h1>
<div class="table_box">
	<table class="list">
		<tbody>
			<tr>
				<th>id</th>
				<th width="35%">标题</th>
				<th width="35%">总结</th>
				<th>姓名</th>
				<th>日期</th>
				<th width="12%">操作</th>
			</tr>
			
			#for(x : page.getList())
			<tr>
				<td style="text-align:left;">#(x.id)</td>
				#if(x.content.length() > 21)
					<td style="text-align:left;" title="#(x.content)">#(x.content.substring(0,20))...</td>
				#else
					<td style="text-align:left;" title="#(x.content)">#(x.content)</td>
				#end

				#if(x.summary.length() > 21)
				<td style="text-align:left;" title="#(x.summary)">#(x.summary.substring(0,20))...</td>
				#else
				<td style="text-align:left;" title="#(x.summary)">#(x.summary)</td>
				#end
				<td style="text-align:left;">#(x.userName)</td>
				<td style="text-align:left;">#date(x.reportDate,"yyyy年MM月dd日")</td>
				<td style="text-align:left;">
					#if((session.uid.id) == (x.userId))
					&nbsp;&nbsp;<a href="#(ctx??)/weekreport/delete/#(x.id)" onclick="if(confirm('确定删除?')==false)return false;">删除</a>
					&nbsp;&nbsp;<a href="#(ctx??)/weekreport/edit/#(x.id)">修改</a>
					#else
						other people
					#end
					<a onclick="openDetail(#(x.id))">查看</a>
					<div id="dialog_#(x.id)" title="内容" style="display:none">
						<p>#(x.content)</p>
					</div>
				</td>
			</tr>
			#end
		</tbody>
		<!--
		分页参数 没有加上
		/weekreport?startTime=#(startTime??)&endTime=#(endTime??)
		  -->
	</table>
	#@paginate(page.pageNumber, page.totalPage, "/weekreport")
</div>
#end